/*
Copyright (c) 2022 Huawei Technologies Co.,Ltd.

openGauss is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:

          http://license.coscl.org.cn/MulanPSL2

THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
import java.sql.*;

public class jdbc_mot_case0299 {
    public static void main(String[] args) throws Exception{
        String url = "jdbc:postgresql://" + args[0] + "/" + args[1];
        String user = args[2];
        String password = args[3];
        Connection connection = DriverManager.getConnection(url, user, password);
        Statement statement = connection.createStatement();
        statement.executeUpdate("drop foreign table if exists t_mot_0299;"
                + "create foreign table t_mot_0299(f1 int, f2 int);");
        statement.executeUpdate("insert into t_mot_0299 values(1,1),(2,2),(3,3);");
        ResultSet resultSet;
        resultSet = statement.executeQuery("select f2 from t_mot_0299 order by f2 desc;");
        while (resultSet.next()) {
            final Object res_object1 = resultSet.getObject("f2");
            System.out.println("res_object1:" + res_object1);
        }
        statement.executeUpdate("drop foreign table if exists t_mot_0299;checkpoint;");
        statement.close();
        connection.close();
    }
}